/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2012/07/17
* File: Singleton.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#ifndef Singleton_h__
#define Singleton_h__

#include "Rfstd.h"

template <typename T>
class Singleton
{
private:
	Singleton(const Singleton<T>&);
	Singleton& operator=(const Singleton<T>&);

protected:
	static T* _singleton;
public:
	Singleton()
	{
		_singleton = static_cast<T*>(this);
	}

	~Singleton()
	{
		_singleton = NULL;
	}

	static T& getSingleton() 
	{
		return *_singleton;
	}

	static T* getSingletonPtr()
	{
		return _singleton;
	}
};

#endif    /* Singleton_h__ */